
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>第四节 正则化 · Tensorflow学习笔记</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="scottdu">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-katex/katex.min.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-alerts/style.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-donate/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="section2.5.html" />
    
    
    <link rel="prev" href="section2.3.html" />
    

    
    <link rel="stylesheet" href="../gitbook/gitbook-plugin-chart/c3/c3.min.css">
    <script src="../gitbook/gitbook-plugin-chart/c3/d3.min.js"></script>
    <script src="../gitbook/gitbook-plugin-chart/c3/c3.min.js"></script>
    

    <script src="../gitbook/gitbook-plugin-graph/d3.min.js"></script>
    <script src="../gitbook/gitbook-plugin-graph/function-plot.js"></script>    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    简介
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../chapter1/">
            
                <a href="../chapter1/">
            
                    
                    第一章 Tensorflow框架
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../chapter1/section1.1.html">
            
                <a href="../chapter1/section1.1.html">
            
                    
                    第一节 张量、计算图、会话
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../chapter1/section1.2.html">
            
                <a href="../chapter1/section1.2.html">
            
                    
                    第二节 前向传播
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../chapter1/section1.3.html">
            
                <a href="../chapter1/section1.3.html">
            
                    
                    第三节 反向传播
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.4" data-path="../chapter1/section1.4.html">
            
                <a href="../chapter1/section1.4.html">
            
                    
                    第四节 搭建神经网络的步骤
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="./">
            
                <a href="./">
            
                    
                    第二章 神经网络优化
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="section2.1.html">
            
                <a href="section2.1.html">
            
                    
                    第一节 损失函数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="section2.2.html">
            
                <a href="section2.2.html">
            
                    
                    第二节 学习率
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="section2.3.html">
            
                <a href="section2.3.html">
            
                    
                    第三节 滑动平均
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.3.4" data-path="section2.4.html">
            
                <a href="section2.4.html">
            
                    
                    第四节 正则化
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="section2.5.html">
            
                <a href="section2.5.html">
            
                    
                    第五节 神经网络的搭建
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../chapter3/">
            
                <a href="../chapter3/">
            
                    
                    第三章 全连接网络基础
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../chapter3/section3.1.html">
            
                <a href="../chapter3/section3.1.html">
            
                    
                    第一节 MINIST数据
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../chapter3/section3.2.html">
            
                <a href="../chapter3/section3.2.html">
            
                    
                    第二节 模块化搭建神经网络方法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../chapter3/section3.3.html">
            
                <a href="../chapter3/section3.3.html">
            
                    
                    第三节 手写数字识别准确率输出
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../chapter4/">
            
                <a href="../chapter4/">
            
                    
                    第四章 全连接网络实践
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../chapter4/section4.1.html">
            
                <a href="../chapter4/section4.1.html">
            
                    
                    第一节 输入手写数字图片输出识别结果
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../chapter4/section4.2.html">
            
                <a href="../chapter4/section4.2.html">
            
                    
                    第二节 制作数据集
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../chapter5/">
            
                <a href="../chapter5/">
            
                    
                    第五章 卷积网络基础
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../chapter5/section5.1.html">
            
                <a href="../chapter5/section5.1.html">
            
                    
                    第一节 卷积神经网络
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../chapter5/section5.2.html">
            
                <a href="../chapter5/section5.2.html">
            
                    
                    第二节 lenel5代码讲解
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../chapter6/">
            
                <a href="../chapter6/">
            
                    
                    第六章 卷积网络实践
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../chapter5/section6.1.html">
            
                <a href="../chapter5/section6.1.html">
            
                    
                    第一节 复现已有的卷积神经网络
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="../chapter6/section6.2.html">
            
                <a href="../chapter6/section6.2.html">
            
                    
                    第二节 用vgg16实现图片识别
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../chapter7/">
            
                <a href="../chapter7/">
            
                    
                    第七章 Tensorflow应用
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >第四节 正则化</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="&#x7B2C;&#x56DB;&#x8282;-&#x6B63;&#x5219;&#x5316;">&#x7B2C;&#x56DB;&#x8282; &#x6B63;&#x5219;&#x5316;</h1>
<ul>
<li>&#x8FC7;&#x62DF;&#x5408;&#xFF1A;&#x795E;&#x7ECF;&#x7F51;&#x7EDC;&#x6A21;&#x578B;&#x5728;&#x8BAD;&#x7EC3;&#x6570;&#x636E;&#x96C6;&#x4E0A;&#x7684;&#x51C6;&#x786E;&#x7387;&#x8F83;&#x9AD8;&#xFF0C;&#x5728;&#x65B0;&#x7684;&#x6570;&#x636E;&#x8FDB;&#x884C;&#x9884;&#x6D4B;&#x6216;&#x5206;&#x7C7B;&#x65F6;&#x51C6;&#x786E;&#x7387;&#x8F83;&#x4F4E;&#xFF0C;&#x8BF4;&#x660E;&#x6A21;&#x578B;&#x7684;&#x6CDB;&#x5316;&#x80FD;&#x529B;&#x5DEE;&#x3002;</li>
<li>&#x6B63;&#x5219;&#x5316;&#xFF1A;&#x5728;&#x635F;&#x5931;&#x51FD;&#x6570;&#x4E2D;&#x7ED9;&#x6BCF;&#x4E2A;&#x53C2;&#x6570;<code>w</code>&#x52A0;&#x4E0A;&#x6743;&#x91CD;&#xFF0C;&#x5F15;&#x5165;&#x6A21;&#x578B;&#x590D;&#x6742;&#x5EA6;&#x6307;&#x6807;&#xFF0C;&#x4ECE;&#x800C;&#x6291;&#x5236;&#x6A21;&#x578B;&#x566A;&#x58F0;&#xFF0C;&#x51CF;&#x5C0F;&#x8FC7;&#x62DF;&#x5408;&#x3002;</li>
</ul>
<p>&#x4F7F;&#x7528;&#x6B63;&#x5219;&#x5316;&#x540E;&#xFF0C;&#x635F;&#x5931;&#x51FD;&#x6570;<code>loss</code>&#x53D8;&#x4E3A;&#x4E24;&#x9879;&#x4E4B;&#x548C;&#xFF1A;</p>
<p><code>loss=loss(y&#x4E0E;y_)+REGULARIZER*loss(w)</code></p>
<p>&#x5176;&#x4E2D;&#xFF0C;&#x7B2C;&#x4E00;&#x9879;&#x662F;&#x9884;&#x6D4B;&#x7ED3;&#x679C;&#x4E0E;&#x6807;&#x51C6;&#x7B54;&#x6848;&#x4E4B;&#x95F4;&#x7684;&#x5DEE;&#x8DDD;&#xFF0C;&#x5982;&#x4E4B;&#x524D;&#x8BB2;&#x8FC7;&#x7684;&#x4EA4;&#x53C9;&#x71B5;&#x3001;&#x5747;&#x65B9;&#x8BEF;&#x5DEE;&#x7B49;&#xFF1B;&#x7B2C;&#x4E8C;&#x9879;&#x662F;&#x6B63;&#x5219;&#x5316;&#x8BA1;&#x7B97;&#x7ED3;&#x679C;&#x3002;</p>
<ul>
<li>&#x6B63;&#x5219;&#x5316;&#x8BA1;&#x7B97;&#x65B9;&#x6CD5;&#xFF1A;</li>
</ul>
<p>(1) <code>L1</code>&#x6B63;&#x5219;&#x5316;: <span class="katex"><span class="katex-mathml"><math><semantics><mrow><mi>l</mi><mi>o</mi><mi>s</mi><msub><mi>s</mi><mrow><mi>L</mi><mn>1</mn></mrow></msub><mo>=</mo><msub><mo>&#x2211;</mo><mrow><mi>i</mi></mrow></msub><mi mathvariant="normal">&#x2223;</mi><msub><mi>w</mi><mrow><mi>i</mi></mrow></msub><mi mathvariant="normal">&#x2223;</mi></mrow><annotation encoding="application/x-tex">loss_{L1}=\sum_{i}|w_{i}|</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height:0.75em;"></span><span class="strut bottom" style="height:1.0500099999999999em;vertical-align:-0.30001em;"></span><span class="base textstyle uncramped"><span class="mord mathit" style="margin-right:0.01968em;">l</span><span class="mord mathit">o</span><span class="mord mathit">s</span><span class="mord"><span class="mord mathit">s</span><span class="msupsub"><span class="vlist"><span style="top:0.15em;margin-right:0.05em;margin-left:0em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle cramped mtight"><span class="mord scriptstyle cramped mtight"><span class="mord mathit mtight">L</span><span class="mord mathrm mtight">1</span></span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span>&#x200B;</span></span></span></span><span class="mrel">=</span><span class="mop"><span class="mop op-symbol small-op" style="top:-0.0000050000000000050004em;">&#x2211;</span><span class="msupsub"><span class="vlist"><span style="top:0.30001em;margin-right:0.05em;margin-left:0em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle cramped mtight"><span class="mord scriptstyle cramped mtight"><span class="mord mathit mtight">i</span></span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span>&#x200B;</span></span></span></span><span class="mord mathrm">&#x2223;</span><span class="mord"><span class="mord mathit" style="margin-right:0.02691em;">w</span><span class="msupsub"><span class="vlist"><span style="top:0.15em;margin-right:0.05em;margin-left:-0.02691em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle cramped mtight"><span class="mord scriptstyle cramped mtight"><span class="mord mathit mtight">i</span></span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span>&#x200B;</span></span></span></span><span class="mord mathrm">&#x2223;</span></span></span></span></p>
<p>&#x7528;Tensorflow&#x51FD;&#x6570;&#x8868;&#x793A;&#xFF1A;</p>
<pre><code>loss(w) = tf.contrib.layers.l1_regularizer(REGULARIZER)(w)
</code></pre><p>(2) <code>L2</code>&#x6B63;&#x5219;&#x5316;: <span class="katex"><span class="katex-mathml"><math><semantics><mrow><mi>l</mi><mi>o</mi><mi>s</mi><msub><mi>s</mi><mrow><mi>L</mi><mn>2</mn></mrow></msub><mo>=</mo><msub><mo>&#x2211;</mo><mrow><mi>i</mi></mrow></msub><mi mathvariant="normal">&#x2223;</mi><msub><mi>w</mi><mrow><mi>i</mi></mrow></msub><msup><mi mathvariant="normal">&#x2223;</mi><mn>2</mn></msup></mrow><annotation encoding="application/x-tex">loss_{L2}=\sum_{i}|w_{i}|^2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height:0.8141079999999999em;"></span><span class="strut bottom" style="height:1.114118em;vertical-align:-0.30001em;"></span><span class="base textstyle uncramped"><span class="mord mathit" style="margin-right:0.01968em;">l</span><span class="mord mathit">o</span><span class="mord mathit">s</span><span class="mord"><span class="mord mathit">s</span><span class="msupsub"><span class="vlist"><span style="top:0.15em;margin-right:0.05em;margin-left:0em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle cramped mtight"><span class="mord scriptstyle cramped mtight"><span class="mord mathit mtight">L</span><span class="mord mathrm mtight">2</span></span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span>&#x200B;</span></span></span></span><span class="mrel">=</span><span class="mop"><span class="mop op-symbol small-op" style="top:-0.0000050000000000050004em;">&#x2211;</span><span class="msupsub"><span class="vlist"><span style="top:0.30001em;margin-right:0.05em;margin-left:0em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle cramped mtight"><span class="mord scriptstyle cramped mtight"><span class="mord mathit mtight">i</span></span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span>&#x200B;</span></span></span></span><span class="mord mathrm">&#x2223;</span><span class="mord"><span class="mord mathit" style="margin-right:0.02691em;">w</span><span class="msupsub"><span class="vlist"><span style="top:0.15em;margin-right:0.05em;margin-left:-0.02691em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle cramped mtight"><span class="mord scriptstyle cramped mtight"><span class="mord mathit mtight">i</span></span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span>&#x200B;</span></span></span></span><span class="mord"><span class="mord mathrm">&#x2223;</span><span class="msupsub"><span class="vlist"><span style="top:-0.363em;margin-right:0.05em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle uncramped mtight"><span class="mord mathrm mtight">2</span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span>&#x200B;</span></span></span></span></span></span></span>
&#x7528;Tensorflow&#x51FD;&#x6570;&#x8868;&#x793A;&#xFF1A;</p>
<pre><code>loss(w) = tf.contrib.layers.l2_regularizer(REGULARIZER)(w)
</code></pre><ul>
<li>&#x7528;Tensorflow&#x51FD;&#x6570;&#x5B9E;&#x73B0;&#x6B63;&#x5219;&#x5316;&#xFF1A;</li>
</ul>
<pre><code>tf.add_to_collection(&apos;losses&apos;,tf.contrib.layers.l2_regularizer(regularizer)(w))
loss = cem + tf.add_n(tf.get_collection(&apos;losses&apos;))
</code></pre><p>&#x5176;&#x4E2D;<code>cem</code>&#x89C1;&#x524D;&#x9762;&#x63D0;&#x5230;&#x7684;&#x3002;</p>
<p>&#x4F8B;&#x5982;&#xFF1A;&#x7528;300&#x4E2A;&#x7B26;&#x5408;&#x6B63;&#x6001;&#x5206;&#x5E03;&#x7684;&#x70B9;<span class="katex"><span class="katex-mathml"><math><semantics><mrow><mi>X</mi><mo>[</mo><msub><mi>x</mi><mrow><mn>0</mn></mrow></msub><mo separator="true">,</mo><msub><mi>x</mi><mrow><mn>1</mn></mrow></msub><mo>]</mo></mrow><annotation encoding="application/x-tex">X[x_{0},x_{1}]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height:0.75em;"></span><span class="strut bottom" style="height:1em;vertical-align:-0.25em;"></span><span class="base textstyle uncramped"><span class="mord mathit" style="margin-right:0.07847em;">X</span><span class="mopen">[</span><span class="mord"><span class="mord mathit">x</span><span class="msupsub"><span class="vlist"><span style="top:0.15em;margin-right:0.05em;margin-left:0em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle cramped mtight"><span class="mord scriptstyle cramped mtight"><span class="mord mathrm mtight">0</span></span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span>&#x200B;</span></span></span></span><span class="mpunct">,</span><span class="mord"><span class="mord mathit">x</span><span class="msupsub"><span class="vlist"><span style="top:0.15em;margin-right:0.05em;margin-left:0em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle cramped mtight"><span class="mord scriptstyle cramped mtight"><span class="mord mathrm mtight">1</span></span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span>&#x200B;</span></span></span></span><span class="mclose">]</span></span></span></span>&#x4F5C;&#x4E3A;&#x6570;&#x636E;&#x96C6;&#xFF0C;&#x6839;&#x636E;&#x70B9;<span class="katex"><span class="katex-mathml"><math><semantics><mrow><mi>X</mi><mo>[</mo><msub><mi>x</mi><mrow><mn>0</mn></mrow></msub><mo separator="true">,</mo><msub><mi>x</mi><mrow><mn>1</mn></mrow></msub><mo>]</mo></mrow><annotation encoding="application/x-tex">X[x_{0},x_{1}]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height:0.75em;"></span><span class="strut bottom" style="height:1em;vertical-align:-0.25em;"></span><span class="base textstyle uncramped"><span class="mord mathit" style="margin-right:0.07847em;">X</span><span class="mopen">[</span><span class="mord"><span class="mord mathit">x</span><span class="msupsub"><span class="vlist"><span style="top:0.15em;margin-right:0.05em;margin-left:0em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle cramped mtight"><span class="mord scriptstyle cramped mtight"><span class="mord mathrm mtight">0</span></span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span>&#x200B;</span></span></span></span><span class="mpunct">,</span><span class="mord"><span class="mord mathit">x</span><span class="msupsub"><span class="vlist"><span style="top:0.15em;margin-right:0.05em;margin-left:0em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle cramped mtight"><span class="mord scriptstyle cramped mtight"><span class="mord mathrm mtight">1</span></span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span>&#x200B;</span></span></span></span><span class="mclose">]</span></span></span></span>&#x8BA1;&#x7B97;&#x751F;&#x6210;&#x6807;&#x6CE8;<code>Y_</code>&#xFF0C;&#x5C06;&#x6570;&#x636E;&#x96C6;&#x6807;&#x6CE8;&#x4E3A;&#x7EA2;&#x8272;&#x70B9;&#x548C;&#x84DD;&#x8272;&#x70B9;&#x3002;&#x6807;&#x6CE8;&#x89C4;&#x5219;&#x4E3A;&#xFF1A;&#x5F53;<span class="katex"><span class="katex-mathml"><math><semantics><mrow><msubsup><mi>x</mi><mrow><mn>0</mn></mrow><mn>2</mn></msubsup><mo>+</mo><msubsup><mi>x</mi><mrow><mn>1</mn></mrow><mn>2</mn></msubsup><mo>&lt;</mo><mn>2</mn></mrow><annotation encoding="application/x-tex">x_{0}^2 + x_{1}^2 &lt; 2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height:0.8141079999999999em;"></span><span class="strut bottom" style="height:1.0622159999999998em;vertical-align:-0.24810799999999997em;"></span><span class="base textstyle uncramped"><span class="mord"><span class="mord mathit">x</span><span class="msupsub"><span class="vlist"><span style="top:0.24810799999999997em;margin-left:0em;margin-right:0.05em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle cramped mtight"><span class="mord scriptstyle cramped mtight"><span class="mord mathrm mtight">0</span></span></span></span><span style="top:-0.363em;margin-right:0.05em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle uncramped mtight"><span class="mord mathrm mtight">2</span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span>&#x200B;</span></span></span></span><span class="mbin">+</span><span class="mord"><span class="mord mathit">x</span><span class="msupsub"><span class="vlist"><span style="top:0.24810799999999997em;margin-left:0em;margin-right:0.05em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle cramped mtight"><span class="mord scriptstyle cramped mtight"><span class="mord mathrm mtight">1</span></span></span></span><span style="top:-0.363em;margin-right:0.05em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle uncramped mtight"><span class="mord mathrm mtight">2</span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span>&#x200B;</span></span></span></span><span class="mrel">&lt;</span><span class="mord mathrm">2</span></span></span></span>&#x65F6;&#xFF0C;<code>y_=1</code>&#xFF0C;&#x6807;&#x6CE8;&#x4E3A;&#x7EA2;&#x8272;&#xFF1B;&#x5F53;<span class="katex"><span class="katex-mathml"><math><semantics><mrow><msubsup><mi>x</mi><mrow><mn>0</mn></mrow><mn>2</mn></msubsup><mo>+</mo><msubsup><mi>x</mi><mrow><mn>1</mn></mrow><mn>2</mn></msubsup><mo>&#x2265;</mo><mn>2</mn></mrow><annotation encoding="application/x-tex">x_{0}^2 + x_{1}^2 \geq 2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height:0.8141079999999999em;"></span><span class="strut bottom" style="height:1.0622159999999998em;vertical-align:-0.24810799999999997em;"></span><span class="base textstyle uncramped"><span class="mord"><span class="mord mathit">x</span><span class="msupsub"><span class="vlist"><span style="top:0.24810799999999997em;margin-left:0em;margin-right:0.05em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle cramped mtight"><span class="mord scriptstyle cramped mtight"><span class="mord mathrm mtight">0</span></span></span></span><span style="top:-0.363em;margin-right:0.05em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle uncramped mtight"><span class="mord mathrm mtight">2</span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span>&#x200B;</span></span></span></span><span class="mbin">+</span><span class="mord"><span class="mord mathit">x</span><span class="msupsub"><span class="vlist"><span style="top:0.24810799999999997em;margin-left:0em;margin-right:0.05em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle cramped mtight"><span class="mord scriptstyle cramped mtight"><span class="mord mathrm mtight">1</span></span></span></span><span style="top:-0.363em;margin-right:0.05em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle uncramped mtight"><span class="mord mathrm mtight">2</span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span>&#x200B;</span></span></span></span><span class="mrel">&#x2265;</span><span class="mord mathrm">2</span></span></span></span>&#x65F6;&#xFF0C;<code>y_=0</code>&#x6807;&#x6CE8;&#x4E3A;&#x84DD;&#x8272;&#x3002;&#x6211;&#x4EEC;&#x5206;&#x522B;&#x7528;&#x65E0;&#x6B63;&#x5219;&#x5316;&#x548C;&#x6709;&#x6B63;&#x5219;&#x5316;&#x4E24;&#x79CD;&#x65B9;&#x6CD5;&#x62DF;&#x5408;&#x66F2;&#x7EBF;&#xFF0C;&#x628A;&#x7EA2;&#x8272;&#x70B9;&#x548C;&#x84DD;&#x8272;&#x70B9;&#x5206;&#x5F00;&#x3002;&#x5728;&#x5B9E;&#x9645;&#x5206;&#x7C7B;&#x65F6;&#xFF0C;&#x5982;&#x679C;&#x524D;&#x5411;&#x4F20;&#x64AD;&#x8F93;&#x51FA;&#x7684;&#x9884;&#x6D4B;&#x503C;<code>y</code>&#x63A5;&#x8FD1;1&#x5219;&#x4E3A;&#x7EA2;&#x8272;&#x70B9;&#x6982;&#x7387;&#x8D8A;&#x5927;&#xFF0C;&#x63A5;&#x8FD1;0&#x5219;&#x4E3A;&#x84DD;&#x8272;&#x70B9;&#x6982;&#x7387;&#x8D8A;&#x5927;&#xFF0C;&#x8F93;&#x51FA;&#x7684;&#x9884;&#x6D4B;&#x503C;<code>y</code>&#x4E3A;0.5&#x662F;&#x7EA2;&#x84DD;&#x70B9;&#x6982;&#x7387;&#x5206;&#x754C;&#x7EBF;&#x3002;</p>
<p>&#x5728;&#x672C;&#x4F8B;&#x5B50;&#x4E2D;&#xFF0C;&#x6211;&#x4EEC;&#x4F7F;&#x7528;&#x4E86;&#x4E4B;&#x524D;&#x672A;&#x7528;&#x8FC7;&#x7684;&#x6A21;&#x5757;&#x4E0E;&#x51FD;&#x6570;:</p>
<ul>
<li><p><code>matplotlib</code>&#x6A21;&#x5757;&#xFF1A;Python&#x4E2D;&#x7684;&#x53EF;&#x89C6;&#x5316;&#x5DE5;&#x5177;&#x6A21;&#x5757;&#xFF0C;&#x5B9E;&#x73B0;&#x51FD;&#x6570;&#x53EF;&#x89C6;&#x5316;&#xFF0C;&#x7EC8;&#x7AEF;&#x5B89;&#x88C5;&#x6307;&#x4EE4;: <code>sudo pip install matplotlib</code></p>
</li>
<li><p>&#x51FD;&#x6570;<code>plt.scatter()</code>:&#x5229;&#x7528;&#x6307;&#x5B9A;&#x989C;&#x8272;&#x5B9E;&#x73B0;&#x70B9;<code>(x,y)</code>&#x7684;&#x53EF;&#x89C6;&#x5316;</p>
</li>
</ul>
<pre><code>plt.scatter(x&#x5750;&#x6807;, y&#x5750;&#x6807;, c=&quot;&#x989C;&#x8272;&quot;)
plt.show()
</code></pre><p>&#x672C;&#x4F8B;&#x4EE3;&#x7801;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code class="lang-python"><span class="hljs-comment">#coding:utf-8</span>
<span class="hljs-comment">#0&#x5BFC;&#x5165;&#x6A21;&#x5757;&#xFF0C;&#x751F;&#x6210;&#x6A21;&#x62DF;&#x6570;&#x636E;&#x96C6;</span>
<span class="hljs-keyword">import</span> tensorflow <span class="hljs-keyword">as</span> tf
<span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np
<span class="hljs-keyword">import</span> matplotlib.pyplot <span class="hljs-keyword">as</span> plt
BATCH_SIZE = <span class="hljs-number">30</span>
seed = <span class="hljs-number">2</span>

<span class="hljs-comment">#&#x57FA;&#x4E8E;seed&#x4EA7;&#x751F;&#x968F;&#x673A;&#x6570;</span>
rdm = np.random.RandomState(seed)
<span class="hljs-comment">#&#x968F;&#x673A;&#x6570;&#x8FD4;&#x56DE;300&#x884C;2&#x5217;&#x7684;&#x77E9;&#x9635;&#xFF0C;&#x8868;&#x793A;300&#x7EC4;&#x5750;&#x6807;&#x70B9;(x0,x1)&#x4F5C;&#x4E3A;&#x8F93;&#x5165;&#x6570;&#x636E;&#x96C6;</span>
X = rdm.randn(<span class="hljs-number">300</span>,<span class="hljs-number">2</span>)
<span class="hljs-comment">#&#x4ECE;X&#x8FD9;&#x4E2A;300&#x884C;2&#x5217;&#x7684;&#x77E9;&#x9635;&#x4E2D;&#x53D6;&#x51FA;&#x4E00;&#x884C;&#xFF0C;&#x5224;&#x65AD;&#x5982;&#x679C;&#x4E24;&#x4E2A;&#x5750;&#x6807;&#x7684;&#x5E73;&#x65B9;&#x548C;&#x5C0F;&#x4E8E;2&#xFF0C;&#x7ED9;Y&#x8D4B;&#x503C;1&#xFF0C;&#x5176;&#x4F59;&#x8D4B;&#x503C;0</span>
<span class="hljs-comment">#&#x4F5C;&#x4E3A;&#x8F93;&#x5165;&#x6570;&#x636E;&#x96C6;&#x7684;&#x6807;&#x7B7E;&#xFF08;&#x6B63;&#x786E;&#x7B54;&#x6848;&#xFF09;</span>
Y = [int(x0*x0+x1*x1 &lt; <span class="hljs-number">2</span>) <span class="hljs-keyword">for</span> (x0,x1) <span class="hljs-keyword">in</span> X]
<span class="hljs-comment">#&#x904D;&#x5386;Y&#x4E2D;&#x7684;&#x6BCF;&#x4E2A;&#x5143;&#x7D20;&#xFF0C;1&#x8D4B;&#x503C;&apos;red&apos;&#x5176;&#x4F59;&#x8D4B;&#x503C;&apos;blue&apos;&#xFF0C;&#x8FD9;&#x6837;&#x53EF;&#x89C6;&#x5316;&#x663E;&#x793A;&#x65F6;&#x4EBA;&#x53EF;&#x4EE5;&#x76F4;&#x89C2;&#x533A;&#x5206;</span>
Y_c = [[<span class="hljs-string">&apos;red&apos;</span> <span class="hljs-keyword">if</span> y <span class="hljs-keyword">else</span> <span class="hljs-string">&apos;blue&apos;</span>] <span class="hljs-keyword">for</span> y <span class="hljs-keyword">in</span> Y_]
<span class="hljs-comment">#&#x5BF9;&#x6570;&#x636E;&#x96C6;X&#x548C;&#x6807;&#x7B7E;Y&#x8FDB;&#x884C;shape&#x6574;&#x7406;&#xFF0C;&#x7B2C;&#x4E00;&#x4E2A;&#x5143;&#x7D20;&#x4E3A;-1&#x8868;&#x793A;&#xFF0C;&#x968F;&#x7B2C;&#x4E8C;&#x4E2A;&#x53C2;&#x6570;&#x8BA1;&#x7B97;&#x5F97;&#x5230;&#xFF0C;&#x7B2C;&#x4E8C;&#x4E2A;&#x5143;&#x7D20;&#x8868;&#x793A;</span>
<span class="hljs-comment">#&#x591A;&#x5C11;&#x5217;&#xFF0C;&#x628A;X&#x6574;&#x7406;&#x4E3A;n&#x884C;2&#x5217;&#xFF0C;&#x628A;Y&#x6574;&#x7406;&#x4E3A;n&#x884C;1&#x5217;</span>
X = np.vstack(X).reshape(<span class="hljs-number">-1</span>,<span class="hljs-number">2</span>)
Y_ = np.vstack(Y_).reshape(<span class="hljs-number">-1</span>,<span class="hljs-number">1</span>)
print(X)
print(Y_)
print(Y_c)
<span class="hljs-comment">#&#x7528;plt.scatter&#x753B;&#x51FA;&#x6570;&#x636E;&#x96C6;X&#x5404;&#x884C;&#x4E2D;&#x7B2C;0&#x5217;&#x5143;&#x7D20;&#x548C;&#x7B2C;1&#x5217;&#x5143;&#x7D20;&#x7684;&#x70B9;&#x5373;&#x5404;&#x884C;&#x7684;(x0,y0)&#xFF0C;&#x7528;&#x5404;&#x884C;Y_c&#x5BF9;&#x5E94;&#x7684;</span>
<span class="hljs-comment">#&#x503C;&#x8868;&#x793A;&#x989C;&#x8272;(c&#x662F;color&#x7684;&#x7F29;&#x5199;)</span>
plt.scatter(X[:,<span class="hljs-number">0</span>],X[:,<span class="hljs-number">1</span>],c=np.squeeze(Y_c))
plt.show()

<span class="hljs-comment">#&#x5B9A;&#x4E49;&#x795E;&#x7ECF;&#x7F51;&#x7EDC;&#x7684;&#x8F93;&#x5165;&#x3001;&#x53C2;&#x6570;&#x548C;&#x8F93;&#x51FA;&#xFF0C;&#x5B9A;&#x4E49;&#x524D;&#x5411;&#x4F20;&#x64AD;&#x8FC7;&#x7A0B;</span>
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">get_weight</span><span class="hljs-params">(shape,regularizer)</span>:</span>
  w = tf.Variable(tf.random_normal(shape),dtype=tf.float32)
  tf.add_to_collection(<span class="hljs-string">&apos;losses&apos;</span>,tf.contrib.layers.l2_regularizer(regularizer)(w))
  <span class="hljs-keyword">return</span> w

<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">get_bias</span><span class="hljs-params">(shape)</span>:</span>
  b = tf.Variable(tf.constant(<span class="hljs-number">0.01</span>,shape=shape))
  <span class="hljs-keyword">return</span> b

x = tf.placeholder(tf.float32, shape(<span class="hljs-keyword">None</span>, <span class="hljs-number">2</span>))
y_ = tf.placeholder(tf.float32, shape(<span class="hljs-keyword">None</span>, <span class="hljs-number">1</span>))

w1 = get_weight([<span class="hljs-number">2</span>,<span class="hljs-number">11</span>],<span class="hljs-number">0.01</span>)
b1 = get_bias([<span class="hljs-number">11</span>])
y1 = tf.nn.relu(tf.matmul(x,w1)+b1)

w2 = get_weight([<span class="hljs-number">11</span>,<span class="hljs-number">1</span>],<span class="hljs-number">0.01</span>)
b2 = get_bias([<span class="hljs-number">1</span>])
y = tf.matmul(y1,w2)+b2 <span class="hljs-comment">#&#x8F93;&#x51FA;&#x5C42;&#x4E0D;&#x8FC7;&#x6FC0;&#x6D3B;</span>

<span class="hljs-comment"># &#x5B9A;&#x4E49;&#x635F;&#x5931;&#x51FD;&#x6570;</span>
loss_mse = tf.reduce_mean(tf.square(y-y_))
loss_total = loss_mse + tf.add_n(tf.get_collection(<span class="hljs-string">&apos;losses&apos;</span>))

<span class="hljs-comment"># &#x5B9A;&#x4E49;&#x53CD;&#x5411;&#x4F20;&#x64AD;&#x65B9;&#x6CD5;&#xFF1A;&#x4E0D;&#x542B;&#x6B63;&#x5219;&#x5316;</span>
train_step = tf.train.AdamOptimizer(<span class="hljs-number">0.0001</span>).minimize(loss_mse)

<span class="hljs-keyword">with</span> tf.Session() <span class="hljs-keyword">as</span> sess:
  init_op = tf.global_variables_initializer()
  sess.run(init_op)
  STEPS = <span class="hljs-number">40000</span>
  <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> range(STEPS):
    start = (i*BATCH_SIZE) % <span class="hljs-number">300</span>
    end = start + BATCH_SIZE
    sess.run(train_step, feed_dict={x:X[start:end], y_:Y_[start:end]})
    <span class="hljs-keyword">if</span> i % <span class="hljs-number">2000</span> == <span class="hljs-number">0</span>:
      loss_mse_v = sess.run(loss_mse, feed_dict={x:X, y_:Y_})
      print(<span class="hljs-string">&quot;After %d steps, loss is: %f&quot;</span> % (i,loss_mse_v))

  <span class="hljs-comment">#xx&#x5728;-3&#x5230;3&#x4E4B;&#x95F4;&#x4EE5;&#x6B65;&#x957F;0.01&#xFF0C;yy&#x5728;-3&#x5230;3&#x4E4B;&#x95F4;&#x4EE5;&#x6B65;&#x957F;0.01&#xFF0C;&#x751F;&#x6210;&#x4E8C;&#x7EF4;&#x7F51;&#x7EDC;&#x5750;&#x6807;&#x70B9;</span>
  xx, yy = np.mgrid(<span class="hljs-number">-3</span>:<span class="hljs-number">3</span>:<span class="hljs-number">.01</span>, <span class="hljs-number">-3</span>:<span class="hljs-number">3</span>:<span class="hljs-number">.01</span>)
  <span class="hljs-comment">#&#x5C06;xx&#xFF0C;yy&#x62C9;&#x76F4;&#xFF0C;&#x5E76;&#x5408;&#x5E76;&#x6210;&#x4E00;&#x4E2A;2&#x5217;&#x7684;&#x77E9;&#x9635;&#xFF0C;&#x5F97;&#x5230;&#x4E00;&#x4E2A;&#x7F51;&#x7EDC;&#x5750;&#x6807;&#x70B9;&#x7684;&#x96C6;&#x5408;</span>
  grid = np.c_[XX.ravel(),yy.ravel()]
  <span class="hljs-comment">#&#x5C06;&#x7F51;&#x7EDC;&#x5750;&#x6807;&#x70B9;&#x5582;&#x5165;&#x795E;&#x7ECF;&#x7F51;&#x7EDC;&#xFF0C;probs&#x4E3A;&#x8F93;&#x51FA;</span>
  probs = sess.run(y, feed_dict={x:grid})
  <span class="hljs-comment">#probs&#x7684;shape&#x8C03;&#x6574;&#x6210;xx&#x7684;&#x6837;&#x5B50;</span>
  probs = probs.reshape(xx.shape)
  print(<span class="hljs-string">&quot;w1:\n&quot;</span>, sess.run(w1))
  print(<span class="hljs-string">&quot;b1:\n&quot;</span>, sess.run(b1))
  print(<span class="hljs-string">&quot;w2:\n&quot;</span>, sess.run(w2))
plt.scatter(X[:<span class="hljs-number">0</span>],X[:,<span class="hljs-number">1</span>],c=np.squeeze(Y_c))
plt.contour(xx,yy,probs,levels=[<span class="hljs-number">.5</span>])
plt.show()

<span class="hljs-comment">#&#x5B9A;&#x4E49;&#x53CD;&#x5411;&#x4F20;&#x64AD;&#x65B9;&#x6CD5;: &#x5305;&#x542B;&#x6B63;&#x5219;&#x5316;</span>
train_step = tf.train.AdamOptimizer(<span class="hljs-number">0.0001</span>).minimize(loss_total)

<span class="hljs-keyword">with</span> tf.Session() <span class="hljs-keyword">as</span> sess:
  init_op = tf.global_variables_initializer()
  sess.run(init_op)
  STEPS = <span class="hljs-number">40000</span>
  <span class="hljs-keyword">for</span> i <span class="hljs-keyword">in</span> range(STEPS):
    start = (i*BATCH_SIZE) % <span class="hljs-number">300</span>
    end = start + BATCH_SIZE
    sess.run(train_step, feed_dict={x:X[start:end], y_:Y_[start:end]})
    <span class="hljs-keyword">if</span> i % <span class="hljs-number">2000</span> == <span class="hljs-number">0</span>:
      loss_v = sess.run(loss_total, feed_dict={x:X,y_:Y_})
      print(<span class="hljs-string">&quot;After %d steps, loss is: %f&quot;</span> %(i, loss_v))

    xx, yy = np.mgrid[<span class="hljs-number">-3</span>:<span class="hljs-number">3</span>:<span class="hljs-number">.01</span>, <span class="hljs-number">-3</span>:<span class="hljs-number">3</span>:<span class="hljs-number">.01</span>]
    grid = np.c_[xx.ravel(), yy.ravel()]
    probs = sess.run(y, feed_dict={x:grid})
    probs = probs.reshape(xx.shape)
    print(<span class="hljs-string">&quot;w1:\n&quot;</span>, sess.run(w1))
    print(<span class="hljs-string">&quot;b1:\n&quot;</span>, sess.run(b1))
    print(<span class="hljs-string">&quot;w2:\n&quot;</span>, sess.run(w2))
    print(<span class="hljs-string">&quot;b2:\n&quot;</span>, sess.run(b2))
plt.scatter(X[:<span class="hljs-number">0</span>],X[:,<span class="hljs-number">1</span>],c=np.squeeze(Y_c))
plt.contour(xx,yy,probs,levels=[<span class="hljs-number">.5</span>])
plt.show()
</code></pre>
<p>&#x6267;&#x884C;&#x4EE3;&#x7801;&#xFF0C;&#x6548;&#x679C;&#x5982;&#x4E0B;&#xFF1A;</p>
<p>&#x9996;&#x5148;&#xFF0C;&#x6570;&#x636E;&#x96C6;&#x5B9E;&#x73B0;&#x53EF;&#x89C6;&#x5316;&#xFF0C;<span class="katex"><span class="katex-mathml"><math><semantics><mrow><msubsup><mi>x</mi><mrow><mn>0</mn></mrow><mn>2</mn></msubsup><mo>+</mo><msubsup><mi>x</mi><mrow><mn>1</mn></mrow><mn>2</mn></msubsup><mo>&lt;</mo><mn>2</mn></mrow><annotation encoding="application/x-tex">x_{0}^2+x_{1}^2 &lt; 2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height:0.8141079999999999em;"></span><span class="strut bottom" style="height:1.0622159999999998em;vertical-align:-0.24810799999999997em;"></span><span class="base textstyle uncramped"><span class="mord"><span class="mord mathit">x</span><span class="msupsub"><span class="vlist"><span style="top:0.24810799999999997em;margin-left:0em;margin-right:0.05em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle cramped mtight"><span class="mord scriptstyle cramped mtight"><span class="mord mathrm mtight">0</span></span></span></span><span style="top:-0.363em;margin-right:0.05em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle uncramped mtight"><span class="mord mathrm mtight">2</span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span>&#x200B;</span></span></span></span><span class="mbin">+</span><span class="mord"><span class="mord mathit">x</span><span class="msupsub"><span class="vlist"><span style="top:0.24810799999999997em;margin-left:0em;margin-right:0.05em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle cramped mtight"><span class="mord scriptstyle cramped mtight"><span class="mord mathrm mtight">1</span></span></span></span><span style="top:-0.363em;margin-right:0.05em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle uncramped mtight"><span class="mord mathrm mtight">2</span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span>&#x200B;</span></span></span></span><span class="mrel">&lt;</span><span class="mord mathrm">2</span></span></span></span>&#x7684;&#x70B9;&#x663E;&#x793A;&#x7EA2;&#x8272;&#xFF0C;<span class="katex"><span class="katex-mathml"><math><semantics><mrow><msubsup><mi>x</mi><mrow><mn>0</mn></mrow><mn>2</mn></msubsup><mo>+</mo><msubsup><mi>x</mi><mrow><mn>1</mn></mrow><mn>2</mn></msubsup><mo>&#x2265;</mo><mn>2</mn></mrow><annotation encoding="application/x-tex">x_{0}^2+x_{1}^2 \geq 2</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height:0.8141079999999999em;"></span><span class="strut bottom" style="height:1.0622159999999998em;vertical-align:-0.24810799999999997em;"></span><span class="base textstyle uncramped"><span class="mord"><span class="mord mathit">x</span><span class="msupsub"><span class="vlist"><span style="top:0.24810799999999997em;margin-left:0em;margin-right:0.05em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle cramped mtight"><span class="mord scriptstyle cramped mtight"><span class="mord mathrm mtight">0</span></span></span></span><span style="top:-0.363em;margin-right:0.05em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle uncramped mtight"><span class="mord mathrm mtight">2</span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span>&#x200B;</span></span></span></span><span class="mbin">+</span><span class="mord"><span class="mord mathit">x</span><span class="msupsub"><span class="vlist"><span style="top:0.24810799999999997em;margin-left:0em;margin-right:0.05em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle cramped mtight"><span class="mord scriptstyle cramped mtight"><span class="mord mathrm mtight">1</span></span></span></span><span style="top:-0.363em;margin-right:0.05em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle uncramped mtight"><span class="mord mathrm mtight">2</span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span>&#x200B;</span></span></span></span><span class="mrel">&#x2265;</span><span class="mord mathrm">2</span></span></span></span>&#x7684;&#x70B9;&#x663E;&#x793A;&#x84DD;&#x8272;&#xFF0C;&#x5982;&#x56FE;&#x6240;&#x793A;&#xFF1A;</p>
<p><img src="http://ovhbzkbox.bkt.clouddn.com/2018-07-29-15328790917732.jpg" width="400"></p>
<p>&#x63A5;&#x7740;&#xFF0C;&#x6267;&#x884C;&#x65E0;&#x6B63;&#x5219;&#x5316;&#x7684;&#x8BAD;&#x7EC3;&#x8FC7;&#x7A0B;&#xFF0C;&#x628A;&#x7EA2;&#x8272;&#x7684;&#x70B9;&#x548C;&#x84DD;&#x8272;&#x7684;&#x70B9;&#x5206;&#x5F00;&#xFF0C;&#x751F;&#x6210;&#x66F2;&#x7EBF;&#x5982;&#x4E0B;&#x56FE;&#x6240;&#x793A;&#xFF1A;</p>
<p><img src="http://ovhbzkbox.bkt.clouddn.com/2018-07-29-15328792396453.jpg" width="400"></p>
<p>&#x6700;&#x540E;&#xFF0C;&#x6267;&#x884C;&#x6709;&#x6B63;&#x5219;&#x5316;&#x7684;&#x8BAD;&#x7EC3;&#x8FC7;&#x7A0B;&#xFF0C;&#x628A;&#x7EA2;&#x8272;&#x7684;&#x70B9;&#x548C;&#x84DD;&#x8272;&#x7684;&#x70B9;&#x5206;&#x5F00;&#xFF0C;&#x751F;&#x6210;&#x66F2;&#x7EBF;&#x5982;&#x4E0B;&#x56FE;&#x6240;&#x793A;&#xFF1A;</p>
<p><img src="http://ovhbzkbox.bkt.clouddn.com/2018-07-29-15328793451699.jpg" width="400"></p>
<p>&#x5BF9;&#x6BD4;&#x65E0;&#x6B63;&#x5219;&#x5316;&#x4E0E;&#x6709;&#x6B63;&#x5219;&#x5316;&#x6A21;&#x578B;&#x7684;&#x8BAD;&#x7EC3;&#x7ED3;&#x679C;&#xFF0C;&#x53EF;&#x770B;&#x51FA;&#x6709;&#x6B63;&#x5219;&#x5316;&#x6A21;&#x578B;&#x7684;&#x62DF;&#x5408;&#x66F2;&#x7EBF;&#x5E73;&#x6ED1;&#xFF0C;&#x6A21;&#x578B;&#x5177;&#x6709;&#x66F4;&#x597D;&#x7684;&#x6CDB;&#x5316;&#x80FD;&#x529B;&#x3002;</p>
<footer class="page-footer"><span class="copyright">Copyright &#xA9; scottdu 2018 all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">&#x8BE5;&#x6587;&#x4EF6;&#x4FEE;&#x8BA2;&#x65F6;&#x95F4;&#xFF1A;
2018-08-18 15:53:44
</span></footer> <link rel="stylesheet" type="text/css" href="https://storage.googleapis.com/app.klipse.tech/css/codemirror.css"> <script>     window.klipse_settings = {         selector: ".language-klipse, .lang-eval-clojure",         selector_eval_js: ".lang-eval-js",         selector_eval_python_client: ".lang-eval-python",         selector_eval_php: ".lang-eval-php",         selector_eval_scheme: ".lang-eval-scheme",         selector_eval_ruby: ".lang-eval-ruby",         selector_reagent: ".lang-reagent",        selector_google_charts: ".lang-google-chart",        selector_es2017: ".lang-eval-es2017",        selector_jsx: ".lang-eval-jsx",        selector_transpile_jsx: ".lang-transpile-jsx",        selector_render_jsx: ".lang-render-jsx",        selector_react: ".lang-react",        selector_eval_markdown: ".lang-render-markdown",        selector_eval_lambdaway: ".lang-render-lambdaway",        selector_eval_cpp: ".lang-eval-cpp",        selector_eval_html: ".lang-render-html",        selector_sql: ".lang-eval-sql",        selector_brainfuck: "lang-eval-brainfuck",        selector_js: ".lang-transpile-cljs"    }; </script> <script src="https://storage.googleapis.com/app.klipse.tech/plugin/js/klipse_plugin.js"></script>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="section2.3.html" class="navigation navigation-prev " aria-label="Previous page: 第三节 滑动平均">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="section2.5.html" class="navigation navigation-next " aria-label="Next page: 第五节 神经网络的搭建">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"第四节 正则化","level":"1.3.4","depth":2,"next":{"title":"第五节 神经网络的搭建","level":"1.3.5","depth":2,"path":"chapter2/section2.5.md","ref":"chapter2/section2.5.md","articles":[]},"previous":{"title":"第三节 滑动平均","level":"1.3.3","depth":2,"path":"chapter2/section2.3.md","ref":"chapter2/section2.3.md","articles":[]},"dir":"ltr"},"config":{"plugins":["katex","expandable-chapters-small","tbfed-pagefooter","alerts","copy-code-button","puml","graph","chart","klipse","donate","simple-page-toc","splitter"],"root":".","styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"Copyright &copy scottdu 2018","modify_label":"该文件修订时间：","modify_format":"YYYY-MM-DD HH:mm:ss"},"puml":{},"simple-page-toc":{"maxDepth":3,"skipFirstH1":true},"splitter":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"graph":{},"donate":{"alipay":"http://ovhbzkbox.bkt.clouddn.com/2018-08-11-alipay1.jpeg","alipayText":"支付宝打赏","button":"赏","title":"","wechat":"http://ovhbzkbox.bkt.clouddn.com/2018-08-11-wechatpay.png","wechatText":"微信打赏"},"katex":{},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"alerts":{},"expandable-chapters-small":{},"copy-code-button":{},"klipse":{"myConfigKey":"it's the default value"},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"chart":{"type":"c3"}},"theme":"default","author":"scottdu","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"Tensorflow学习笔记","language":"zh-hans","gitbook":"3.2.3","description":"记录Tensorflow的学习内容"},"file":{"path":"chapter2/section2.4.md","mtime":"2018-08-18T07:53:44.136Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2018-09-25T05:55:22.995Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-alerts/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-copy-code-button/toggle.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-donate/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

